package cn.gene.timeyan.coo.webapi.controller;


import cn.gene.timeyan.common.restful.JsonResult;
import cn.gene.timeyan.coo.service.ApplyService;
import cn.gene.timeyan.pojo.coo.dto.ApplyDTO;
import cn.gene.timeyan.pojo.coo.vo.CooperationVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 浜掑姪鎻??璁板綍琛 前端控制器
 * </p>
 *
 * @author LWG
 * @since 2022-07-25
 */
@Slf4j
@RestController
@RequestMapping("/apply")
@Api(tags = "apply模块")
public class ApplyController {
    /**
     * cyn
     */
    @Autowired(required = false)
    private ApplyService applyService;

    @GetMapping("/list/{userId}/{page}")
    @ApiOperation("获取用户待帮助列表")
    public JsonResult<List<CooperationVO>> userNotFinishedList(@PathVariable(value = "userId") Long userId,@PathVariable(value = "page") Integer page){
        return applyService.userNotFinishedList(userId,page);
    }
    @ApiOperation("揭榜功能")
    @PostMapping("/addApply")
    public JsonResult<Void> addNew(@Validated @RequestBody ApplyDTO applyDTO){
        log.info("dto====:{}",applyDTO);
        applyService.addApply(applyDTO);
        return JsonResult.ok();
    }
}

